package com.gjy.kafka.java.cons;

import org.apache.kafka.clients.consumer.ConsumerConfig;

import java.util.Properties;

import static org.apache.kafka.clients.CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG;
import static org.apache.kafka.clients.consumer.ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG;
import static org.apache.kafka.clients.consumer.ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG;
import static org.apache.kafka.clients.producer.ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG;
import static org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-09-07 11:41:52
 */
public class KafkaUtil {

    public static Properties produceConfig() {
        Properties properties = new Properties();
        properties.put(BOOTSTRAP_SERVERS_CONFIG, KafkaConstant.BOOTSTRAP_SERVICES);
        properties.put(KEY_SERIALIZER_CLASS_CONFIG, KafkaConstant.KEY_SERIALIZER);
        properties.put(VALUE_SERIALIZER_CLASS_CONFIG, KafkaConstant.VALUE_SERIALIZER);
        return properties;
    }

    public static Properties consumerConfig() {
        Properties properties = new Properties();
        properties.put(BOOTSTRAP_SERVERS_CONFIG, KafkaConstant.BOOTSTRAP_SERVICES);
        properties.put(KEY_DESERIALIZER_CLASS_CONFIG, KafkaConstant.KEY_DESERIALIZER);
        properties.put(VALUE_DESERIALIZER_CLASS_CONFIG, KafkaConstant.VALUE_DESERIALIZER);
        properties.put(ConsumerConfig.GROUP_ID_CONFIG, KafkaConstant.CONSUMER.SIMPLE_CONSUMER_GROUP);
        properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
        properties.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
        return properties;
    }

}
